//Copyright (C) 2012 Chirila Alexandru
//This file is part of Robo-GoldMiner
//
//Robo-GoldMiner is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//Robo-GoldMiner is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with Robo-GoldMiner.  If not, see <http://www.gnu.org/licenses/>.

package gold;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

/**
 * This command set or unset the skip field of {@link Maze}. 
 * This specifies if the next command will or will not execute.
 * Sintax: on {name of color} <br />
 * Possible names of colors: "red", "green", "blue" 
 * @author Alexandru Chirila
 */
public class CommandOn implements Command, Serializable{

	private static final long serialVersionUID = 4230666997938410622L;

	private String color;
	
	private Maze m;
	
	public CommandOn(Maze m){
		this.m = m;
	}
	
	public boolean execute() throws EndGame, ParseException {
		return m.checkConditionalColor(color);
	}

	public String getColor() {
		return color;
	}

	public void setColor(String color) {
		this.color = color;
	}
	
	private void writeObject(ObjectOutputStream stream) throws IOException {
		stream.defaultWriteObject();
	}

	private void readObject(ObjectInputStream stream) throws IOException,
			ClassNotFoundException {
		stream.defaultReadObject();
	}


}
